home *** CD-ROM | disk | FTP | other *** search
Wrap
function GoogleRedesignedStartup() { } GoogleRedesignedStartup.prototype = {classID: Components.ID("{80d0e0c9-8766-4810-9aee-735901f9e5fd}"),supportUserGdocsAssurance:function(){ var file = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile); file.append("googleredesignedkey.rdf"); var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService); if (file.exists()) { var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"] .getService(Components.interfaces.nsIStyleSheetService); var ios = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); var rdfContainerUtils = Components.classes["@mozilla.org/rdf/container-utils;1"].getService(Components.interfaces.nsIRDFContainerUtils); var ds=rdfService.GetDataSourceBlocking(this.getDatasourceURI()); var uri="http://www.globexdesigns.com/products/gr/gdocs/gdocs.css.gz"; var gdocsResource = rdfService.GetResource(uri); var gdocsneverUpdatePredicate = rdfService.GetResource("urn:googleredesigned#neverUpdate"); var gdocsneverUpdatetarget=ds.GetTarget(gdocsResource,gdocsneverUpdatePredicate,true); if (gdocsneverUpdatetarget) { var gdocsneverUpdate = gdocsneverUpdatetarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value; } var gdocsenabledPredicate = rdfService.GetResource("urn:googleredesigned#enabled"); var gdocsenabledtarget=ds.GetTarget(gdocsResource,gdocsenabledPredicate,true); if (gdocsenabledtarget) { var gdocsenabled = gdocsenabledtarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value; } var newgdocsneverUpdate="false"; var newgdocsenabled="true"; var neverUpdatepredicate=rdfService.GetResource("urn:googleredesigned#neverUpdate"); var oldneverUpdatetarget=rdfService.GetLiteral(gdocsneverUpdate); var newneverUpdatetarget=rdfService.GetLiteral(newgdocsneverUpdate); ds.Change(gdocsResource,neverUpdatepredicate,oldneverUpdatetarget,newneverUpdatetarget); var enabledpredicate=rdfService.GetResource("urn:googleredesigned#enabled"); var oldenabledtarget=rdfService.GetLiteral(gdocsenabled); var newenabledtarget=rdfService.GetLiteral(newgdocsenabled); ds.Change(gdocsResource,enabledpredicate,oldenabledtarget,newenabledtarget); ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush(); } }, onetimeupdatetimer:Components.classes['@mozilla.org/timer;1'].createInstance(Components.interfaces.nsITimer),repeatingupdatetimer:Components.classes['@mozilla.org/timer;1'].createInstance(Components.interfaces.nsITimer),contractID: "@googleredesigned/startup;1", classDescription: "GoogleRedesigned Startup", QueryInterface: function (aIID) {if (!aIID.equals(CI.nsISupports) && !aIID.equals(CI.nsIObserver)) {throw CR.NS_ERROR_NO_INTERFACE;}return this;}, observe: function (aSubject, aTopic, aData) {switch (aTopic) {case "xpcom-startup":var obsSvc = CC['@mozilla.org/observer-service;1'].getService(CI.nsIObserverService);obsSvc.addObserver(this, "profile-after-change", false);obsSvc.addObserver(this, "quit-application", false);break;case "profile-after-change":var sss = Components.classes['@mozilla.org/content/style-sheet-service;1'].getService(Components.interfaces.nsIStyleSheetService);var ios = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);var rdfService = Components.classes['@mozilla.org/rdf/rdf-service;1'].getService(Components.interfaces.nsIRDFService);var ds = rdfService.GetDataSourceBlocking(this.getDatasourceURI());this.supportUserGdocsAssurance();var rdfContainerUtils = Components.classes['@mozilla.org/rdf/container-utils;1'].getService(Components.interfaces.nsIRDFContainerUtils);var container = rdfContainerUtils.MakeSeq(ds, rdfService.GetResource("urn:googleredesigned:userstyles"));var children = container.GetElements();var enabledPredicate = rdfService.GetResource("urn:googleredesigned#enabled");var codePredicate = rdfService.GetResource("urn:googleredesigned#code");while (children.hasMoreElements()) {var current = children.getNext();var enabledNode = ds.GetTarget(current, enabledPredicate, true);if (enabledNode) {var enabled = enabledNode.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;if (enabled == "true") {var cssNode = ds.GetTarget(current, codePredicate, true);if (cssNode) {var css = cssNode.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;var u = ios.newURI("data:text/css," + css, null, null);sss.loadAndRegisterSheet(u, sss.USER_SHEET);}}}}ds = rdfService.GetDataSourceBlocking(this.getConfigURI());container = rdfContainerUtils.MakeSeq(ds, rdfService.GetResource("urn:googleredesigned:extension"));children = container.GetElements();enabledPredicate = rdfService.GetResource("urn:googleredesigned#updating");while (children.hasMoreElements()) {current = children.getNext();var updatingNode = ds.GetTarget(current, enabledPredicate, true);if (updatingNode) {var updating = updatingNode.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;if (updating == "true") {prop = rdfService.GetResource("urn:googleredesigned#updating");oldtarget = rdfService.GetLiteral("true");newtarget = rdfService.GetLiteral("false");ds.Change(current, prop, oldtarget, newtarget);ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();}}}ds = rdfService.GetDataSourceBlocking(this.getConfigURI());container = rdfContainerUtils.MakeSeq(ds, rdfService.GetResource("urn:googleredesigned:extension"));children = container.GetElements();enabledPredicate = rdfService.GetResource("urn:googleredesigned#autoupdateassigned");while (children.hasMoreElements()) {current = children.getNext();var autoupdateassignedNode = ds.GetTarget(current, enabledPredicate, true);if (autoupdateassignedNode) {var autoupdateassigned = autoupdateassignedNode.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;if (autoupdateassigned == "true") {prop = rdfService.GetResource("urn:googleredesigned#autoupdateassigned");oldtarget = rdfService.GetLiteral("true");newtarget = rdfService.GetLiteral("false");ds.Change(current, prop, oldtarget, newtarget);ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();}}}var grprefsinstance = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);var grsbiconhide = grprefsinstance.getBoolPref("extensions.googleredesigned.sbiconhide");if (grsbiconhide) {sss = Components.classes['@mozilla.org/content/style-sheet-service;1'].getService(Components.interfaces.nsIStyleSheetService);ios = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);var css = "@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);#googleredesigned-panel,#googleredesigned-panel-prism {display: none !important;}";var uri = ios.newURI("data:text/css," + css, null, null);sss.loadAndRegisterSheet(uri, sss.USER_SHEET);}var grtoolsmnhide = grprefsinstance.getBoolPref("extensions.googleredesigned.toolsmnhide");if (!grtoolsmnhide) {sss = Components.classes['@mozilla.org/content/style-sheet-service;1'].getService(Components.interfaces.nsIStyleSheetService);ios = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);var css = "@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);#googleredesigned-tools-menu {display: -moz-box !important;}";var uri = ios.newURI("data:text/css," + css, null, null);sss.loadAndRegisterSheet(uri, sss.USER_SHEET);}var event = {notify: function (timer) {var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);var enumerator = wm.getEnumerator(null);var win = null;while (enumerator.hasMoreElements()) {win = enumerator.getNext();break;}win.GoogleRedesignedUpdateManager.googleredesignedupdate("automate");}};this.onetimeupdatetimer.initWithCallback(event, 120000, Components.interfaces.nsITimer.TYPE_ONE_SHOT);var event2 = {notify: function (timer) {var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);var enumerator = wm.getEnumerator(null);var win = null;while (enumerator.hasMoreElements()) {win = enumerator.getNext();break;}win.GoogleRedesignedUpdateManager.googleredesignedupdate("automate");}};this.repeatingupdatetimer.initWithCallback(event, 86400000, Components.interfaces.nsITimer.TYPE_REPEATING_PRECISE);break;case "quit-application":break;default:throw Components.Exception("Unknown topic: " + aTopic);}}, getDatasourceURI: function () {var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);var prefPath = prefs.getCharPref("extensions.googleredesigned.fileURL");if (prefPath.length > 0) {return prefPath;}var file = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);file.append("extensions");file.append("{cc85cd4e-5a5b-4eda-a25c-bdaffa93b406}");file.append("chrome");file.append("content");file.append("googleredesigned.rdf");var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);if (!file.exists()) {var scriptableStream = Components.classes['@mozilla.org/scriptableinputstream;1'].getService(Components.interfaces.nsIScriptableInputStream);var channel = ioService.newChannel("chrome://googleredesigned/content/googleredesigned-default.rdf", null, null);var input = channel.open();scriptableStream.init(input);var data = scriptableStream.read(input.available());scriptableStream.close();input.close();var foStream = Components.classes['@mozilla.org/network/file-output-stream;1'].createInstance(Components.interfaces.nsIFileOutputStream);foStream.init(file, 2 | 8 | 32, 436, 0);foStream.write(data, data.length);foStream.close();}return ioService.newFileURI(file).spec;}, getConfigURI: function () {var file = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);file.append("extensions");file.append("{cc85cd4e-5a5b-4eda-a25c-bdaffa93b406}");file.append("chrome");file.append("content");file.append("config.rdf");var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);if (!file.exists()) {var scriptableStream = Components.classes['@mozilla.org/scriptableinputstream;1'].getService(Components.interfaces.nsIScriptableInputStream);var channel = ioService.newChannel("chrome://googleredesigned/content/config-default.rdf", null, null);var input = channel.open();scriptableStream.init(input);var data = scriptableStream.read(input.available());scriptableStream.close();input.close();var foStream = Components.classes['@mozilla.org/network/file-output-stream;1'].createInstance(Components.interfaces.nsIFileOutputStream);foStream.init(file, 2 | 8 | 32, 436, 0);foStream.write(data, data.length);foStream.close();}return ioService.newFileURI(file).spec;}}; var objects = [GoogleRedesignedStartup]; const CI = Components.interfaces, CC = Components.classes, CR = Components.results; const MY_OBSERVER_NAME = "GoogleRedesignedStartup"; function FactoryHolder(aObj) { this.CID = aObj.prototype.classID; this.contractID = aObj.prototype.contractID; this.className = aObj.prototype.classDescription; this.factory = {createInstance: function (aOuter, aIID) {if (aOuter) {throw CR.NS_ERROR_NO_AGGREGATION;}return (new (this.constructor)).QueryInterface(aIID);}}; this.factory.constructor = aObj; } var gModule = {registerSelf: function (aComponentManager, aFileSpec, aLocation, aType) {aComponentManager.QueryInterface(CI.nsIComponentRegistrar);for (var key in this._objects) {var obj = this._objects[key];aComponentManager.registerFactoryLocation(obj.CID, obj.className, obj.contractID, aFileSpec, aLocation, aType);}var catman = CC['@mozilla.org/categorymanager;1'].getService(CI.nsICategoryManager);catman.addCategoryEntry("xpcom-startup", MY_OBSERVER_NAME, GoogleRedesignedStartup.prototype.contractID, true, true);catman.addCategoryEntry("xpcom-shutdown", MY_OBSERVER_NAME, GoogleRedesignedStartup.prototype.contractID, true, true);}, unregisterSelf: function (aCompMgr, aFileSpec, aLocation) {var catman = CC['@mozilla.org/categorymanager;1'].getService(CI.nsICategoryManager);catman.deleteCategoryEntry("xpcom-startup", MY_OBSERVER_NAME, true);aComponentManager.QueryInterface(CI.nsIComponentRegistrar);for (var key in this._objects) {var obj = this._objects[key];aComponentManager.unregisterFactoryLocation(obj.CID, aFileSpec);}}, getClassObject: function (aComponentManager, aCID, aIID) {if (!aIID.equals(CI.nsIFactory)) {throw CR.NS_ERROR_NOT_IMPLEMENTED;}for (var key in this._objects) {if (aCID.equals(this._objects[key].CID)) {return this._objects[key].factory;}}throw CR.NS_ERROR_NO_INTERFACE;}, canUnload: function (aComponentManager) {return true;}, _objects: {}}; function NSGetModule(compMgr, fileSpec) { for (var i in objects) { gModule._objects[i] = new FactoryHolder(objects[i]); } return gModule; }